<template>
    <el-form :inline="true" :model="form" style="margin:20px" :rules="rules" ref="ruleForm" label-width="120px">
        <el-card class="box-card">
            <div>
                <span style="line-height:36px">医生信息</span>
                <el-button type="primary" style="float:right;background-color:rgb(118,149,255);border-color:rgb(118,149,255)" @click="submitDoctorInfo('ruleForm')">通过审核</el-button>
                <el-button type="primary" style="float:right;background-color:red;border-color:rgb(118,149,255);margin-right:10px" @click="refuseDoctorInfo('ruleForm')">拒绝审核</el-button>
            </div>
            <div style="margin-top:60px;">
                <el-form-item label="姓名" prop="Name">
                    <el-tag type="info">{{form.Name}}</el-tag>
                </el-form-item>
                <el-form-item label=" 所属医院" prop="HospitalName">
                    <el-tag type="info">{{form.HospitalName}}</el-tag>
                </el-form-item>
                <el-form-item label=" 职称" prop="JobTitle">
                    <el-tag type="info">{{form.JobTitle}}</el-tag>
                </el-form-item>
                <el-form-item label=" 擅长癌种" prop="GoodATCancer">
                    <el-tag type="info">{{form.GoodATCancer}}</el-tag>
                </el-form-item>
                <div style="text-align:center;margin:30px 0 30px;"><span>本人照片</span></div>
                <div style="text-align:center"><img :src="headImgSrc" alt="" style="width:30%;"></div>
                <div style="text-align:center;margin:30px 0 30px;"><span>医院工牌照片</span></div>
                <div style="text-align:center"><img :src="workImgSrc" alt="" style="width:30%;"></div>
            </div>
        </el-card>
    </el-form>
</template>
<script>
import {approvalDoctor} from '../../api/api'
export default {
    props:['doctorInfo'],
    data(){
        return{
            form:'',
            headImgSrc:'',
            workImgSrc:''
        }
    },
    methods:{
        setUserInfo:function(){
            if(this.doctorInfo){
                this.form=this.doctorInfo;
                // 头像照片和工作照片地址
                let imgSrcHead="http://www.bestckd.com/lungtest/remotewardrounds/";
                this.headImgSrc=imgSrcHead+this.form.AvatarUrl;
                this.workImgSrc=imgSrcHead+this.form.CertifiedUrl;
            }
        },
        submitDoctorInfo:function(){
            let param={
                Status:2,
                UserId:this.form.Id
            }
            this.$confirm('是否通过审核？','提示',{
                    confirmButtonText:'确定',
                    cancelButtonText:'取消',
                    type:'warning'
                }).then(()=>{
                    approvalDoctor(param).then(res=>{
                        if(res.data.IsSuccess){
                            this.$message({
                                 type:'success',
                                 message:'已通过审核'
                            });
                            this.$emit('getNew');
                        }else{
                            this.$message({
                                 type:'success',
                                 message:'审核失败，请稍后再试'
                            });
                            this.$emit('getNew');
                        }
                    })
                }).catch(()=>{
                    this.$message({
                        message: "已取消"
                    });
                })
        },
        refuseDoctorInfo:function(){
            let param={
                Status:3,
                UserId:this.form.Id
            }
            this.$confirm('是否拒绝审核？','提示',{
                    confirmButtonText:'确定',
                    cancelButtonText:'取消',
                    type:'warning'
                }).then(()=>{
                    approvalDoctor(param).then(res=>{
                        if(res.data.IsSuccess){
                            this.$message({
                                 type:'success',
                                 message:'已拒绝审核'
                            });
                            this.$emit('getNew');
                        }else{
                            this.$message({
                                 type:'success',
                                 message:'拒绝审核失败，请稍后再试'
                            });
                            this.$emit('getNew');
                        }
                    })
                }).catch(()=>{
                    this.$message({
                        message: "已取消"
                    });
                })
        }
    },
    watch:{
       'doctorInfo':function(){
           this.setUserInfo();
       } 
    },
    mounted(){
        this.setUserInfo();
    }
}
</script>
<style lang="scss" scoped>

</style>


